package comxin.object;

import org.junit.Test;

public class object_Test1 {
    //测试Object的equals
    @Test
    public void testEquals1(){
        Equals equals1 = new Equals();
        Equals equals2 = new Equals();
        System.out.println(equals1.equals(equals2));
    }
    //练习String的equals方法
    @Test
    public void testEquals2(){
        String name1=new String("hh");
        String name2=new String("hh");
        String name3=name1;
        System.out.println(name3==name1);
        System.out.println(name1==name2);
        System.out.println(name1.equals(name2));
    }
    //练习instanceof关键字
    @Test
    public void testInstanceOf(){
        Cat_Object cat_object = new Cat_Object();
        System.out.println(cat_object instanceof Animal_Object);
        Animal_Object animal_object = new Animal_Object();
        System.out.println(animal_object instanceof Cat_Object);
    }
    // 测试自己些equals方法中遇到的问题
    @Test
    public void testMyEquals1(){
        Equals equals1 = new Equals();
        String equals2="123";
        System.out.println(equals1.myEquals(equals2));
    }
    @Test
    public void testMyEquals2(){
        Equals equals1 = new Equals();
        Equals equals2 = new Equals("李四");
        System.out.println(equals1.myEquals(equals2));
    }
    @Test
    public void testMyEquals3(){
        Cat_Object cat1 = new Cat_Object("喵喵");
        Cat_Object cat2 = new Cat_Object("喵喵");
        System.out.println(cat1.myEquals(cat2));

    }
    @Test
    public void testEmployeeEquals(){
        Manager_Object manager_object=new Manager_Object("张三",100);
        Employee_Object employee_object=new Employee_Object("张三",100);
//        System.out.println(manager_object.myEquals(employee_object));

        System.out.println(employee_object.myEquals(manager_object));
    }
    //测试hashcode
    @Test
    public void method1(){
//        Cat_Object cat_object = new Cat_Object();
//        cat_object.hashCode();
//        System.out.println( );
        String name=new String("zh");
        String name2="lisi";
        int i = name.hashCode();
String jd="h";
        System.out.println(i);

    }


}
